#include "ThreadPool.hpp"
#include "Task.hpp"
#include "log.hpp"
#include <iostream>
#include <time.h>
#include <unistd.h>

int main()
{
    // logMessage(DEBUG, "%s-%d", "test", 6);
    ThreadPool<Task> tp;
    tp.run();
    char types[] = {'+', '-', '*', '/'};

    auto func = [](int x, int y, int type){
        switch(type)
        {
        case '+':
            return x + y;
            break;
        case '-':
            return x - y;
            break;
        case '/':
            return x / y;
            break;
        case '*':
            return x * y;
            break;
        }
    };

    srand(time(nullptr) ^ getpid());
    while (true)
    {
        // std::cout << "1" << std::endl;
        int x = rand() % 10 + 1;
        int y = rand() % 10 + 1;
        Task task(x, y, types[rand() % 4], func);
        usleep(rand() % 1000);
        tp.pushTask(task);
        sleep(1);
    }

    return 0;
}